package com.example.dairenkun.neufoodshop.adapter;

import android.content.Context;
import android.content.SharedPreferences;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.widget.TextView;
;

import com.example.dairenkun.neufoodshop.R;

import com.example.dairenkun.neufoodshop.bean.Order;


import java.util.List;


;

/**
 * Created by Administrator on 2017/3/6.
 */

public class FoodCommentAdapter extends RecyclerView.Adapter<ViewHolder> {
    int userid;
    private Context mContext;
    private List mDataList;
    private LayoutInflater mLayoutInflater;
    public FoodCommentAdapter(Context mContext, List mDataList){
        this.mContext = mContext;
        this.mDataList = mDataList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = mLayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_foodcomment, parent, false);
        return new ViewHolder(v);

    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
       final Order entity=(Order) mDataList.get(position);
        if (null == entity)
            return;
        ViewHolder viewHolder = (ViewHolder) holder;
        viewHolder.username.setText(entity.getUsername());
       viewHolder.commentContent.setText(entity.getContent());
       /* if (!"".equals(entity.getPic()))
        Picasso.with(mContext).load(entity.getPic()).into(viewHolder.food_image);*/

    }


    @Override
    public int getItemCount() {
        return mDataList.size();
    }
    public class ViewHolder extends RecyclerView.ViewHolder{
        TextView username;
       TextView commentContent;

        public ViewHolder(View itemView) {
            super(itemView);
            username = (TextView) itemView.findViewById(R.id.comment_username);
            commentContent=(TextView)itemView.findViewById(R.id.comment_usercomment);

        }

    }
    private void getUser(){
        SharedPreferences sp = mContext.getSharedPreferences("UserInfo", mContext.MODE_PRIVATE);
        userid = Integer.valueOf(sp.getString("user_id", null));
    }
}
